import Vue from 'vue'


import Cookies from 'js-cookie'

import Element from 'element-ui'
import './assets/styles/element-variables.scss'

import i18n from './assets/i18n/index.js'

import '@/assets/styles/index.scss' // global css
import '@/assets/styles/ruoyi.scss' // ruoyi css
import App from './App'
import store from './store'
import router from './router'
import plugins from './plugins' // plugins

/**
 * 定义全局工具相关方法
 */
import utils from '@/utils/index'
Object.keys(utils).map(fn=>{
  Vue.prototype[fn] = utils[fn];
})

import './assets/icons' // icon
import './permission' // permission control
import { getDicts } from "@/api/system/dict/data";
import { getConfigKey } from "@/api/system/config";
// 分页组件
import Pagination from "@/components/Pagination";
// 自定义表格工具组件
import RightToolbar from "@/components/RightToolbar"
// 富文本组件
import Editor from "@/components/Editor"
// 字典标签组件
import DictTag from '@/components/DictTag'
// 头部标签组件
import VueMeta from 'vue-meta'
// 字典数据组件
import DictData from '@/components/DictData'

// 全局方法挂载
Vue.prototype.getDicts = getDicts
Vue.prototype.getConfigKey = getConfigKey

// 全局组件挂载
Vue.component('DictTag', DictTag)
Vue.component('Pagination', Pagination)
Vue.component('RightToolbar', RightToolbar)
Vue.component('Editor', Editor)

// 全局组件挂载
import baseComponents from './baseComponents/index'
Object.keys(baseComponents).map(key => {
  Vue.component(key, baseComponents[key])
})
import auth from '@/plugins/auth'
Object.keys(auth).map(key=>{
  Vue.prototype[key] = auth[key];
})
Vue.use(plugins)
Vue.use(VueMeta)
DictData.install()


/**
 * 自定义指令操作
 */
import directive from './directive' // directive
Vue.use(directive)

/**
* 注册全局过滤器 
*/ 
import * as filters from './filters' // 全局过滤器
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key]);
  Vue.prototype[key] = filters[key];
})

/**注入全局mixins */
import mixins from './mixins'
mixins.map(mixin=>{
  Vue.mixin(mixin);
})

Vue.use(Element, {
  size: Cookies.get('size') || 'medium', // set element-ui default size
  i18n: (key, value) => i18n.t(key, value)
})

Vue.config.productionTip = false
Vue.config.silent = true
Vue.config.devtools = true

new Vue({
  el: '#app',
  router,
  store,
  i18n,
  render: h => h(App)
})
